import Vue from 'vue';
export const badge = {
  update (el, binding) {
    const { value } = binding;
    //微标数字大于0才会显示
    if (value[Object.keys(value)[0]] > 0) {
      const targetTemplate = `<div style="background:#ed5b56;position:absolute;top:-8px;right:-9px;height:14px;display:inline-block;white-space: nowrap;border-radius:15px;min-width:15px;text-align:center;line-height:14px;color:#fff;padding:0 4px;font-size: 2px">${value[Object.keys(value)[0]]}</div>`;
      el.style.position = el.style.position || 'relative';
      const badge = Vue.extend({
        template: targetTemplate
      });
      const component = new badge().$mount().$el;
      el.appendChild(component);
    }
  }
};